package com.meisupic.copyright.controller;

import com.meisupic.copyright.domain.vo.QuestionAnswerVo;
import com.meisupic.copyright.service.ICopyrightHelpService;
import com.meisupic.copyright.support.Message;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/questions")
public class QuestionAnswerController {

  @Autowired
  ICopyrightHelpService copyrightHelpService;

  @GetMapping("/list")
  public Message<List<QuestionAnswerVo>> getAllQuestions() {
    List<QuestionAnswerVo> questionAnswerVos = copyrightHelpService.findAllQuestions();
    return Message.success(questionAnswerVos);
  }

  @GetMapping("getQuestionById")
  public Message<QuestionAnswerVo> getQuestionById(Long id) {
    if(id==null){
      return Message.success(null);
    }
    QuestionAnswerVo vo = copyrightHelpService.findQuestionById(id);
    return Message.success(vo);
  }
}
